#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define end '\n'

void solve() {
	int n; cin >> n;
	string s; cin >> s;
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == '@') sum++;
		if (s[i] == '*' && s[i + 1] == '*') break;
	}
	cout << sum << endl;
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int t; cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}